Color in color imaging systems generally is represented as vector coordinates in a three dimensional “color space.” Common examples include the well-known RGB, YIQ and YUV color spaces. The RGB color space specifies a color using coordinates that represent intensities of red, green and blue light, respectively (also known as “tristimulus” values). The RGB color space is well suited for output devices such as CRT (cathode ray tube) computer monitors, which produce color by exciting red, green and blue phosphors with an electron beam at varying intensity.
A default, standard RGB color space (termed the “sRGB” color space) has been defined to support the unambiguous interchange of color image data between devices with differing color reproduction characteristics (e.g., between scanners, displays, printers, cameras and other imaging devices, which may have different gamut, as well as red, green and blue color reproduction chromaticities and luminance). (See, International Electrotechnical Commission, “Colour Measurement And Management In Multimedia Systems And Equipment,” IEC61966-2-1 (1998).)
The sRGB color space is a perceptual color representation, which represents the appearance to a viewer of color on a reference monitor under reference viewing conditions. The coordinates in the sRGB color space have a non-linear relationship to actual luminance in the three respective chromaticities that closely fits a simple power function of exponent 2.2. (This exponent is sometimes referred to as the color space's “gamma” or γ). This perceptual color space is advantageous in that it closely matches the native color space of many devices (e.g.; displays, scanners and digital cameras). For example, common CRT displays have a non-linear relationship of electron-gun voltage to phosphor luminance also fitting an exponential function.
It has been shown, however, that perceptual color spaces are not ideally suitable for many standard image-processing operations, such as filtering, anti-aliasing and blending. For best results, these image processing operations ideally should be performed using a physical color representation having a linear relationship to light intensity (i.e., γ=1). (See, e.g., Ward Larson, Greg and Rob Shakespeare, Rendering with Radiance, Morgan-Kauffman (1998).) An example of a physical color space is the scRGB color space, described in IEC 61966-2-2.
As per the sRGB standard, the conversion between the perceptual sRGB color space and a physical color space is defined using the following equations. (The sRGB color values are integer numbers in the range 0 to 255, whereas physical color values are floating point numbers in the range 0 to 1.)
                                          R            sRGB            ′                    =                                    R                              8                ⁢                bit                                      ÷            255.0                                                                    G            sRGB            ′                    =                                    G                              8                ⁢                bit                                      ÷            255.0                                                                    B            sRGB            ′                    =                                    B                              8                ⁢                bit                                      ÷            255.0                                 (1)                                                         R              sRGB                        =                          {                                                                                                                  R                        sRGB                        ′                                            ÷                      12.92                                                                                                                          if                        ⁢                                                                                                  ⁢                                                  R                          sRGB                          ′                                                                    ≤                      0.03928                                                                                                                                                          [                                                                              (                                                                                          R                                sRGB                                ′                                                            +                              0.055                                                        )                                                    /                          1.055                                                ]                                            2.4                                                                            otherwise                                                                                                                                      G              sRGB                        =                          {                                                                                                                  G                        sRGB                        ′                                            ÷                      12.92                                                                                                                          if                        ⁢                                                                                                  ⁢                                                  G                          sRGB                          ′                                                                    ≤                      0.03928                                                                                                                                                          [                                                                              (                                                                                          G                                sRGB                                ′                                                            +                              0.055                                                        )                                                    /                          1.055                                                ]                                            2.4                                                                            otherwise                                                                                                                                      B              sRGB                        =                          {                                                                                                                  B                        sRGB                        ′                                            ÷                      12.92                                                                                                                          if                        ⁢                                                                                                  ⁢                                                  B                          sRGB                          ′                                                                    ≤                      0.03928                                                                                                                                                          [                                                                              (                                                                                          B                                sRGB                                ′                                                            +                              0.055                                                        )                                                    /                          1.055                                                ]                                            2.4                                                                            otherwise                                                                                                  (2)
The inverse transform (i.e., physical color space to sRGB color space) is as follows.
                              R          sRGB          ′                =                ⁢                  {                                                                      12.92                  ×                                      R                    sRGB                                                                                                                    if                    ⁢                                                                                  ⁢                                          R                      sRGB                                                        ≤                  0.00304                                                                                                                          1.055                    ×                                          R                      sRGB                                              (                                                  1.0                          /                          2.4                                                )                                                                              -                  0.055                                                            otherwise                                                                                      G          sRGB          ′                =                ⁢                  {                                                                      12.92                  ×                                      G                    sRGB                                                                                                                    if                    ⁢                                                                                  ⁢                                          G                      sRGB                                                        ≤                  0.00304                                                                                                                          1.055                    ×                                          G                      sRGB                                              (                                                  1.0                          /                          2.4                                                )                                                                              -                  0.055                                                            otherwise                                                                                      B          sRGB          ′                =                ⁢                  {                                                                      12.92                  ×                                      B                    sRGB                                                                                                                    if                    ⁢                                                                                  ⁢                                          B                      sRGB                                                        ≤                  0.00304                                                                                                                          1.055                    ×                                          B                      sRGB                                              (                                                  1.0                          /                          2.4                                                )                                                                              -                  0.055                                                            otherwise                                                        (3)                                                         R                              8                ⁢                bit                                      =                          255.0              ×                              R                sRGB                ′                                                                                                    G                              8                ⁢                bit                                      =                          255.0              ×                              G                sRGB                ′                                                                                                    B                              8                ⁢                bit                                      =                          255.0              ×                              B                sRGB                ′                                                                (4)
As can be seen from the above equations, these conversions involve calculating power functions with the exponent, 2.4. The calculation of such a power function using a floating-point instruction on conventional microprocessors consumes a relatively long time to compute. Further, given constraints on cache memory during image processing, an implementation of the conversion as a large look-up table also would be slow. Consequently, it becomes impractical to perform the perceptual-to-physical color space conversion for anti-aliasing and like image processing, and the reverse physical-to-perceptual color space conversion during real-time image renderings with such implementations.
A like problem arises with other perceptual color spaces that also ideally would be converted to physical color space representations for some image processing operations. For example, a CRT monitor that has γ=2.5 relationship of electron gun voltage to phosphor luminance would ideally convert images between representations using a device-specific RGB color space (with γ=2.5) and a physical color space (γ=1) for blending and anti-aliasing image processing operations.
The present invention provides efficient conversion between perceptual (γ≠1) and physical (γ=1) color spaces, and like applications involving difficult to calculate exponents. In accordance with the invention, a conversion involving a computationally expensive power function(s) of a variable is implemented by mathematically combining the results of any number of computationally less expensive functions of the variable. Such computationally less expensive functions generally are functions that can be composed of a small number of square roots, reciprocal square roots, reciprocals, multiplications and/or additions and subtractions. The combination of computationally less expensive functions can be an arithmetic mean, harmonic mean, weighted sum or difference, or other mathematical combination of the functions.
In accordance with one aspect of the invention, the computationally less expensive functions are composed of a small number of single instruction multiple data floating-point (SIMD FP) instruction set operations. Such SIMD FP operations on modern processors allow software to use single instructions to perform a same floating-point operation on packed operands, such as a range of multiple consecutive color values in an image.
In accordance with one embodiment of the invention for sRGB/physical color space conversions for example, the power function of exponent 2.4 (i.e., x2.4) in the sRGB to physical color space conversion is approximated utilizing the following weighted harmonic mean:
      x    2.4    ≈      1.285                  (                  0.285          +                      x                          -              0.5                                      )            ⁢              x                  -          2                    The expressions x−2 and x−0.5 can be computed quickly with two and one SIMD FP instructions, respectively. Specifically, x−2 is the square of the reciprocal, and x−0.5 is the reciprocal square root.
On the other hand, the inverse power x1/2.4 in the inverse physical-to-sRGB conversion can be approximated with a weighted arithmetic mean of the two functions x0.5 and x0.375, both of which are computationally inexpensive on a processor where the square root is computationally inexpensive. The function x0.375 can be evaluated as three successive square roots.
Alternatively, the function x1/2.4 can be evaluated using a Newton-Raphson iteration for the cube root.
      (                  x                  1          /          2.4                    =                        x          1.25                3              )    .
More generally, alternative embodiments of the invention for perceptual/physical color space conversion approximate a conversion involving a power function with exponents in the range between 1.7 and 2.5 (e.g., the sRGB power function x2.4) as a combination of one or more of the computationally less expensive functions. Examples of such computationally less expensive functions include power functions with exponents in the range between 1 and 3 composed from square, square root and reciprocal operations, such as the following:
                              x          1.25                =                  x          ⁢                                    x                                                                        x          1.5                =                  x          ⁢                      x                                                            x          1.75                =                              x            ·            x                                              x                                                                        x          2                =                  x          ·          x                                                  x          2.25                =                              x            ·            x                    ⁢                                    x                                                                        x          2.3125                =                              x            ·            x                    ⁢                                                    x                                      ·                                                                                x                                                                                                                        x          2.5                =                  x          ·          x          ·                      x                              
For the conversion from physical back to sRGB or other perceptual color space, the alternative embodiments approximate the inverse power function x−1/2.4 (or other power function with exponent in the range of −1/1.8 and −1/2.5) as a combination of one or more inverse power functions in a similar range. Some examples include:
                              x          0.25                =                              x                                                            x          0.375                =                              x                    /                                                    x                                                                                      x          0.5                =                  x                    
Additionally, the invention can be applied to efficiently approximate computationally expensive power functions in other perceptual/physical conversion applications in addition to imaging, such as perceptual/physical conversion of audio and touch data. Further, the efficient approximation of power functions according to the invention can be employed in applications other than those involving perceptual/physical data conversions that require evaluation of computationally expensive power functions.
Additional features and advantages will be made apparent from the following detailed description of the illustrated embodiment, which proceeds with reference to the accompanying drawings.